//
//  GWMeViewController.m
//  百思不得姐
//
//  Created by qianfeng on 16/3/1.
//  Copyright (c) 2016年 高炜. All rights reserved.
//

#import "GWMeViewController.h"
#import "GWMeTableVIewCell.h"
#import "GWMeTableViewFooterView.h"
#import <AFNetworking.h>
#import "GWSquare.h"
#import <MJExtension.h>
@interface GWMeViewController ()

@end

@implementation GWMeViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self setNavgationbar];
    
    [self.tableView registerClass:[GWMeTableVIewCell class] forCellReuseIdentifier:@"me"];
    self.tableView.sectionHeaderHeight =0;
    self.tableView.sectionFooterHeight =10;
    self.tableView.contentInset =UIEdgeInsetsMake(-25, 0, 0, 0);
    
    NSDictionary *parame =@{
                            @"a":@"square",
                            @"c":@"topic"
                            };
    [[AFHTTPSessionManager manager] GET:@"http://api.budejie.com/api/api_open.php" parameters:parame progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
      NSArray *squareArray = [GWSquare mj_objectArrayWithKeyValuesArray:responseObject[@"square_list"]];
        GWMeTableViewFooterView *footView =[[GWMeTableViewFooterView alloc]init];
        footView.squareArray =squareArray;
        self.tableView.tableFooterView = footView;
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        
    }];
}
-(void)setNavgationbar
{
    self.navigationItem.title =@"我的";
    self.navigationItem.rightBarButtonItems =@[[UIBarButtonItem itemWithImage:@"mine-setting-icon" highLightImage:@"mine-setting-icon-click" target:self action:@selector(settingBtnOnClick)],[UIBarButtonItem itemWithImage:@"mine-moon-icon" highLightImage:@"mine-moon-icon-click" target:self action:@selector(moonBtnOnClick)]];
    
    self.view.backgroundColor =GWGlobalBGColor;
}

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 2;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 1;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    GWMeTableVIewCell *cell =[tableView dequeueReusableCellWithIdentifier:@"me"];
    if (indexPath.section==0) {
        cell.imageView.image =[[UIImage imageNamed:@"defaultUserIcon"]cycleImage ];
        cell.textLabel.text =@"登录/注册";
    }
    else
    {
        cell.textLabel.text =@"离线下载";
    }
    return cell;
}
-(void)settingBtnOnClick
{
    
}
-(void)moonBtnOnClick
{
    
}


@end
